<template>
    <div>
      <div class="pay-type">
        <span>商&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;品</span>
        <div>
          <input type="text" v-model="data.goods_name" disabled>
        </div>
      </div>
      <div class="pay-type">
        <span>规&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格</span>
        <div>
          <input type="text" v-model="data.norm.norm" disabled>
        </div>
      </div>
      <div class="pay-type">
        <span>价&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格</span>
        <div>
          <input type="number" placeholder="请输入价格" v-model="data.norm.price">
        </div>
      </div>
      <div class="pay-type">
        <span>数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量</span>
        <div>
          <input type="number" placeholder="请输入数量" v-model="data.num">
        </div>
      </div>
      <div class="pay-type">
        <span>客户签字</span>
        <div class="weui-uploader" @click="upClick" v-if="data.sign_img">
          <img :src="data.sign_img" class="uploadImg"/>
        </div>
        <div v-if="!data.sign_img" style="color: #999">暂无客户签名</div>
        <!--<upload v-show="up" @upload="upload2" @uploadReady="fileReady" style="display: none;"></upload>-->
      </div>
      <!--<div class="update-btn">-->
        <!--<router-link :to="{path:'/project0/view1/signature', query:{uid:orderId}}">修改客户签名</router-link>-->
      <!--</div>-->

      <div style="text-align: right;border-top: 1px #f1f1f1 solid;margin: 1rem;">
        <x-button style="background: #ffc655;color: #fff;" mini @click.native="none">取消</x-button>
        <x-button style="background: #33bb99;color: #fff;" mini @click.native="yes">确定</x-button>
      </div>
    </div>
</template>

<script>
  import upload from '../common/Upload'
    export default {
      name: "",
      components:{
        upload
      },
      props:['goodsDetail','orderId'],
      data () {
        return {
          data:'',
          up:false,
          baseImg: 'https://dlhz.oss-cn-beijing.aliyuncs.com/xey-upload/F76Rc5SemZ.png',
        }
      },
      created(){
        console.log(this.goodsDetail)
        this.goodsDetail.norm.price = Number(this.goodsDetail.norm.price)
        this.goodsDetail.num = Number(this.goodsDetail.num)
        this.data = this.goodsDetail
      },
      methods:{
        none(){
          this.$emit('toDetail',false)
        },
        // 税务登记证
        upload2(file){
          this.info.tax_registration_img = this.config1.fileUrl+file;
          this.$vux.loading.hide();
        },
        fileReady(){
          $('#post-files').click();
          this.$vux.loading.show();
        },
        // 点击初始化上传图片
        upClick(){
          console.log(1)
          this.up = true
        },
        yesVerify(){
          if(this.data.norm.price==''){
            this.msg('价格不能为空');
            return false
          }else{
            let reg = /^[0-9]*$/
            if (!reg.test(this.data.norm.price)){
              this.msg('价格必须为数字');
              return false;
            }
          }
          if(this.data.num==''){
            this.msg('数量不能为空');
            return false
          }else{
            let reg = /^[0-9]*$/
            if (!reg.test(this.data.num)){
              this.msg('数量必须为数字');
              return false;
            }
          }
          return true
        },
        yes(){
          if(!this.yesVerify()) return false;
          this.$vux.loading.show();
          let obj = {
            orderId:this.orderId,
            detailId:this.goodsDetail.id,
            price:Number(this.goodsDetail.norm.price),
            num:Number(this.goodsDetail.num),
            signImg:this.goodsDetail.sign_img
          }
          this.config0.post('/supply/appOrder/update', {jsonStr:JSON.stringify(obj)}).then(res=>{
            this.$vux.loading.hide();
            if(res.data.code==='0'){
              this.$emit('toDetail',true)
            }else{
              this.msg(this.config0.handleError(res.data));
            }
          })
        },
        // 信息提示
        msg(str){
          this.$vux.toast.show({
            type: 'text',
            text: str,
            position: 'default',
            time: 800,
          });
        },
      }
    }
</script>

<style scoped lang="less">
  .update-btn{
    width: 90%;
    margin:0 auto;
    text-align:right;
    a{
      display: inline-block;
      background: #10aeff;
      padding:0 1rem;
      line-height: 2rem;
      border-radius: 5px;
      color: #fff;
    }
  }
  .weui-uploader{
    width: 100%;
    height:150px;
    border:1px #f1f1f1 solid;
    text-align: center;
    background: #fff;
    border-radius: 5px;
    margin-top: 10px;
    img{
      height:100%;
      transform:rotate(-90deg);
      -ms-transform:rotate(-90deg); 	/* IE 9 */
      -moz-transform:rotate(-90deg); 	/* Firefox */
      -webkit-transform:rotate(-90deg); /* Safari 和 Chrome */
      -o-transform:rotate(-90deg);	/* Opera */
    }
  }
  .pay-type{
    width: 90%;
    margin: 0.8rem auto;
    line-height:1.8rem;
    display: flex;
    justify-content: space-between;
  span{
    color: #999;
    width: 22%;
  }
  div{
    width: 78%;
  .checker{
    display: flex;
    justify-content: space-between;
  }
  .remark-text{
    padding:0.5rem;border-radius: 5px;line-height: 1.8rem;border:1px #f1f1f1 solid;
  }
  input{
    outline: none;
    line-height: 1.8rem;
    border:0;
    border:1px #f1f1f1 solid;
    padding: 0 0.5rem;
    border-radius: 5px;
  }
  }
  }
</style>
